;
; ------------------------------------------------------------
;
;   PureBasic - Image example file
;
;    (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;


If OpenWindow(0, 100, 100, 500, 300, "PureBasic - Image")

  Gosub CreateImage
      
  Repeat
    EventID = WaitWindowEvent()
    
    If EventID = #PB_Event_Repaint
      StartDrawing(WindowOutput(0))
        DrawImage(ImageID(0), 20, 10)
        DrawImage(ImageID(1), 320, 80)
        DrawImage(ImageID(2), 320, 200)
      StopDrawing()    
    EndIf
    
  Until EventID = #PB_Event_CloseWindow  ; If the user has pressed on the close button
  
EndIf

End   ; All the opened windows are closed automatically by PureBasic


;
; Some 2D graphics functions...
;

CreateImage:

  If CreateImage(0, 255, 255)

    StartDrawing(ImageOutput(0))
    
    For k=0 To 255
      FrontColor(RGB(k,0, k))  ; a rainbow, from black to pink
      Line(0, k, 255, 0)
    Next

    DrawingMode(1)
    FrontColor(RGB(255,255,255)) ; print the text to white !
    DrawText(40, 50, "An image created easely...")

    StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
    
  EndIf
  
  CopyImage(0, 1)
  ResizeImage(1, 100, 100)
  
  GrabImage(0, 2, 100, 60, 150, 40)

Return    
; IDE Options = PureBasic v4.02 (Windows - x86)
; CursorPosition = 17
; FirstLine = 22
; Folding = -